package rearrangeCharacters;

import java.util.HashMap;
import java.util.Map;

public class Solution {
    public int rearrangeCharacters(String s, String target) {
        // 返回数目最少的
        int[] cnt1 = new int[26];
        for (int i = 0; i < target.length(); i++) {
            cnt1[target.charAt(i)-'a']++;
        }
        int[] cnt2 = new int[26];
        for (int i = 0; i < s.length(); i++) {
            cnt2[s.charAt(i)-'a']++;
        }
        int ans = 100000;
        for (int i = 0; i < 26; i++) {
            if(cnt1[i]!=0) {
                ans = Math.min(ans,cnt2[i]/cnt1[i]);
            }
        }
        return ans;
    }
}
